#define _CRT_SECURE_NO_WARNINGS 1
#include"Heap.h"
void HeapSort(int* a, int n)
{
	int k = n;
	for (int i = (n - 2) / 2; i >= 0; i--)
	{
		AdjustDown(a, n, i);
	}
	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	while (k>0)
	{
		Swap(&a[0], &a[k - 1]);
		k--;
		AdjustDown(a, k, 0);
	}
	for (int i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
}

int main()
{
	int a[] = { 1, 48, 25, 326, 504, 16, 116 };
	int num = sizeof(a) / sizeof(a[0]);
	/*HP hp;
	HeapInit(&hp);
	for (int i = 0; i < sizeof(a) / sizeof(int); i++)
	{
		HeapPush(&hp, a[i]);
	}
	HeapPrint(&hp);
	while (!HeapEmpty(&hp))
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}

	HeapDestroy(&hp);*/
	printf("%d\n", num);
	HeapSort(a, num);
	return 0;
}

